﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Web.Security;

namespace ZhaoPin.Feature
{
    public partial class GetHousehold : System.Web.UI.Page
    {
        protected StringBuilder sb;
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid guid = (Guid)Membership.GetUser().ProviderUserKey;
            sb = new StringBuilder();
            RecruitContainer rc = new RecruitContainer();
            var stories = from hh in rc.Households where hh.PersonId.Equals(guid) select hh;
            if (stories.Any())
            {
                List<Household> listStories = stories.ToList();
                listStories.ToList<Household>().ForEach(es => { writeOneHousehold(es); });
                sb.Remove(sb.Length - 2, 2);
                Response.Write(sb.ToString());
                Response.End();
            }
            else
            {
                Response.Write("");
                Response.End();
            }
            rc.Dispose();
        }
        protected void writeOneHousehold(Household es)
        {
            paraStart();
            sb.Append(es.Name);
            appendSpace(2);
            sb.Append(es.TDictGender.FName);
            appendSpace(2);
            sb.Append(es.TDictRelation.FName);
            appendSpace(2);
            sb.Append(es.TDictParty.FName);
            appendSpace(2);
            sb.Append(es.Company);
            appendSpace(2);
            sb.Append(es.Headship);
            paraEnd();
        }
        protected void appendSpace(int count)
        {
            for (int i = 0; i < count; i++)
                sb.Append(" ");
        }
        protected void paraStart()
        {
        }
        protected void paraEnd()
        {
            sb.Append("\r\n");
        }
    }
}